const path=require('path')
const HtmlWebpackPlugin=require("html-webpack-plugin")
const TestPlugin = require('./plugins/01_test')

module.exports={
    entry:"./src/main.js",
    output:{
        path:path.resolve(__dirname,"./dist"),
        filename:"js/[name].js",
        clean:true
    },
    module:{
        rules:[
            {
                test:/\.js$/,
                // use:[//先执行test2
                //     './loaders/demo/test1',
                //     './loaders/demo/test2'
                // ]
                // loader:'./loaders/demo/test3'
                loader:'./loaders/API/banner/index.js',
                options:{
                    author:"老王",
                    // 一个选项就开启additionalProperties为false
                }
            },
            {
                test:/\.js$/,
                
                loader:'./loaders/API/babel/index.js',
                options:{
                    // 把高版本的代码转换成低版本的浏览器可以识别的代码
                    presets:["@babel/preset-env"],
                    // 一个选项就开启additionalProperties为false
                }
            },
            {
                test:/\.(png|jpe?g|gif)$/,
                loader:"./loaders/API/file-loader",
                type: "javascript/auto", 
                // 阻止webpack默认处理图片资源，只使用file-loader处理
            },
            {
                test:/\.css$/,
                use:["style-loader","css-loader"],
                
            }
        ],
    },
    plugins:[
        new HtmlWebpackPlugin({
            template:path.resolve(__dirname,"public/index.html")
        }),
        new TestPlugin(),
    ],
    mode:"development",
       
    
}